// 执行特殊功能的封装函数



// 把时间戳转化为日期
function getTime(time) {
    // 需要先创建时间对象
    let date = new Date(time),
        accurateDate = '';

    accurateDate += date.getFullYear() + '-';
    accurateDate += date.getMonth() + 1 + '-';
    accurateDate += date.getDate();

    return accurateDate;
}



// 转化播放量的函数
function transformCounts(counts) {
    if (counts >= 1000) {
        // 把播放量转化为 以万为单位、只保留一位小数的形式
        let integerPart = parseInt(counts / 10000);
        let decimalPart = parseInt(counts / 1000) - integerPart * 10;
        let finalCounts = `${integerPart}.${decimalPart}万`;

        return finalCounts;
    } else {
        return counts;
    }
}



// 获取时长的函数
function getDuration(duration) {
    let time = parseInt(duration / 1000),
        minute = parseInt(time / 60),
        second = time - minute * 60;

    minute = minute > 10 ? minute : '0' + minute;
    second = second > 10 ? second : '0' + second;

    return `${minute}:${second}`;
}



// 把时间转化为毫秒形式的函数
function getMilisecond(time) {

    let time1 = time.split(':'),
        minute = 0,
        second = 0,
        milisecond = 0;

    // 分
    let handleMinute = time1[0];

    if (handleMinute[0] == 0 && handleMinute[1] == 0) {
        minute = 0;
    } else if (handleMinute[0] == 0 && handleMinute[1] !== 0) {
        minute = parseInt(handleMinute[1]);
    } else {
        minute = parseInt(handleMinute);
    }

    // 秒
    let handleSecond = time1[1].split('.')[0];

    if (handleSecond[0] == 0 && handleSecond[1] == 0) {
        second = 0;
    } else if (handleSecond[0] == 0 && handleSecond[1] !== 0) {
        second = parseInt(handleSecond[1]);
    } else {
        second = parseInt(handleSecond);
    }

    // 毫秒
    let handleMili = time1[1].split('.')[1];

    if (handleMili[0] == 0 && handleMili[1] == 0) {
        if (handleMili.length == 3) {
            milisecond = parseInt(handleMili[2]);
        } else {
            milisecond = 0;
        }
    } else if (handleMili[0] == 0 && handleMili[1] !== 0) {
        milisecond = parseInt(handleMili[1] + handleMili[2]);
    } else if (handleMili[0] !== 0) {
        milisecond = parseInt(handleMili);
    }

    return minute * 60000 + second * 1000 + milisecond;
}



// 获取下一个兄弟节点
function getNextElementSibling(element) {
    let ele = element;

    while (ele = ele.nextSibling) {
        if (ele.nodeType === 1) {
            return ele;
        }
    }

    return null;
}